package com.jspgou.cms.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.springframework.stereotype.Repository;

import com.jspgou.common.hibernate3.Finder;
import com.jspgou.common.hibernate3.HibernateBaseDao;
import com.jspgou.common.page.Pagination;
import com.jspgou.cms.dao.AftersaleDemandDao;
import com.jspgou.cms.entity.AftersaleDemand;

@Repository
public class AftersaleDemandDaoImpl extends HibernateBaseDao<AftersaleDemand, Long> implements AftersaleDemandDao {
	public Pagination getPage(int pageNo, int pageSize) {
		Criteria crit = createCriteria();
		Pagination page = findByCriteria(crit, pageNo, pageSize);
		return page;
	}

	public AftersaleDemand findById(Long id) {
		AftersaleDemand entity = get(id);
		return entity;
	}
	
	@SuppressWarnings("unchecked")
	public List<AftersaleDemand> findAll(){
		Finder f=Finder.create("from AftersaleDemand bean ");
		return find(f);
	}

	public AftersaleDemand save(AftersaleDemand bean) {
		getSession().save(bean);
		return bean;
	}

	public AftersaleDemand deleteById(Long id) {
		AftersaleDemand entity = super.get(id);
		if (entity != null) {
			getSession().delete(entity);
		}
		return entity;
	}
	
	@Override
	protected Class<AftersaleDemand> getEntityClass() {
		return AftersaleDemand.class;
	}
}